//
//  UILabel+DDAdd.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/4.
//

import UIKit

extension UILabel {
    func setLineSpacing(lineSpacing: CGFloat,alignment : NSTextAlignment = .center) {
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineSpacing = lineSpacing
        paragraphStyle.alignment = alignment// 设置文本居中        
        let attributedString = NSMutableAttributedString(string: self.text ?? "")
        attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))
        
        self.attributedText = attributedString
    }
}

